define(['../deviceModule'], function(module) {
	module.controller("addDeviceCtrl", ['$scope', '$rootScope', '$sessionStorage','$timeout', 'httpService', 'ENV','growl', 'Upload', 'ngDialog', 'Md5', function($scope, $rootScope, $sessionStorage,$timeout, httpService, ENV, growl, Upload, ngDialog, Md5) {
		'use strict';
        console.log(1);
        $scope.addDevice = function(valid) {

			if (valid) {
				// 禁用按钮
				$scope.disableFlag = true;

				var data = $scope.addDevInfo;

				httpService.linkHttp({
					url: ENV.deviceAdd
				},data).then(function(res) {
					// 判断请求成功
					var result = res.data;
					if (result.code == "000000") {
						// 重置表单
						$scope.addDevInfo = {};
						$scope.date = {};
						growl.addSuccessMessage("新增成功,可继续新增");
					} else {
						var errText;
						result.errDesc ? errText = result.errDesc : errText = '新增失败, 请稍后再尝试';
						growl.addErrorMessage(errText);
					}
					$scope.disableFlag = false;
				});
			} else {
				$scope.chechErrorForm($scope.addDeviceForm.$error);
			}
		}


	}])
});
